import React, { Component } from 'react';

import { View, Checkbox, CheckboxGroup } from 'remax/wechat';

class CustomList extends Component {
  handleChange = (id) => {
    this.props.delTodo(id);
  }
  render() {
    let { list } = this.props;
    let listItems = list.length > 0 ? list.map(item => {
      return (
        <View key={item.id}>
          <CheckboxGroup bindchange={this.handleChange.bind(this, item.id)}>
            <Checkbox checked={item.finished}>{item.name}</Checkbox>
          </CheckboxGroup>
        </View>
      )
    }) : <div>Opps, nothing...</div>
    return (
      <View className="list-wrapper">
        <View>{listItems}</View>
      </View>
    )
  }
}

export default CustomList;